Options for pack method are | |
---|---|
x, y | Horizontal and vertical offset in pixels. |
height, width | Height and width in pixels. |
relx, rely | Horizontal and vertical offset as a float between 0.0 and 1.0, as a fraction of the height and width of the parent widget. |
relheight, relwidth | Height and width as a float between 0.0 and 1.0, as a fraction of the height and width of the parent widget. |
from tkinter import * class MyFrame(Tk): def __init__(self): super().__init__() self.geometry("200x200") self.b1=Button(self,text="Save",bg="red") self.b1.place(x=0,y=0,width=100,height=50) self.b2=Button(self,text="Cancel",bg="blue") self.b2.place(x=100,y=150,width=100,height=50) frm=MyFrame() frm.mainloop()
from tkinter import * class MyFrame(Tk): def __init__(self): super().__init__() self.geometry("200x200") self.b1=Button(self,bg="yellow") self.b1.place(relx=0.0,rely=0.0,relwidth=1.0,relheight=0.75 ) self.b2=Button(self,bg="blue") self.b2.place(relx=0.0,rely=0.75,relwidth=0.5,relheight=0.25) self.b3=Button(self,bg="red") self.b3.place(relx=0.5,rely=0.75,relwidth=0.5,relheight=0.25) frm=MyFrame() frm.mainloop()